<!--container begin-->

<script type="text/javascript">

function postqty(qty,th,th_price){

	var old_qty = $("#qty"+th).val();
	
	var current_qty = parseInt(old_qty)+parseInt(qty);

	if(current_qty<1)return;

	$("#qty"+th).val(current_qty);

	var tot = current_qty*th_price*<?php echo $currency->rate;?>;
	
	$("#sub_tot_dis"+th).html(tot.toFixed(2));

	$.post("/changeqty",{product_id:th,qty:current_qty},function(msg){

		msg = eval('('+msg+')');
		$("#sub_tot").html(msg.symbol + msg.subtotal);
		$("#shippfee").html(msg.symbol + msg.shippingfee);
		$("#tot").html(msg.symbol + (parseFloat(msg.subtotal)+parseFloat(msg.shippingfee)));
	  	  
	});

}

function isNumberKey(evt)
{   
	  var charCode = (evt.which) ? evt.which : event.keyCode;
	  if (charCode = 46 && charCode > 31 && (charCode < 48 || charCode > 57))
	  return false;
}

function change_qty(th,th_price)
{	
	var qty=$("#qty"+th).val();
	var tot=qty*th_price*<?php echo $currency->rate;?>;
	$("#sub_tot_dis"+th).html(tot.toFixed(2));
	var qstring = 'qty='+qty+'&product_id='+th;
	$.ajax({  
		type: "POST",  
		url: "/changeqty",  
		data: qstring ,
		success: function(msg){	
		msg = eval('('+msg+')');
		$("#sub_tot").html(msg.symbol + msg.subtotal);
		$("#shippfee").html(msg.symbol + msg.shippingfee);
		$("#tot").html(msg.symbol + (parseFloat(msg.subtotal)+parseFloat(msg.shippingfee)));
		} 
	}); 

}
</script>

<div id="container" class="fix">
	<div class="cartWrapper">

		<div class="bagStep">

			<ul>
				<li class="stepB">
					<span>1</span>
					Shopping Basket
				</li>
				<li class="stepD">
					<span>2</span>
					Shipping Address
				</li>
				<li class="stepE">
					<span>3</span>
					Make the Payment
				</li>
			</ul>
		</div>
		<div class="cartPro">
			<h3>Shopping Basket</h3>
			<div class="bagArea">
				<div class="itmetotal">
					Your Shopping Basket Contains
					<span><?php echo $pro_item;?> Item(s)</span>
				</div>
				<table class="cartTable">
					<tr class="title">
						<th class="itemName">SKU</th>
						<th class="itemDetail">Product Name</th>
						<th class="size">Weight</th>
						<th class="bagQty">Qty</th>
						<th class="bagPrice">Price Each</th>
						<th class="totalPrice">Subtotal</th>
						<th class="action">Remove</th>
					</tr>
              <?php $subtotal = 0; ?>
              <?php foreach ($cart_info as $item):?>
              <tr>
						<td class="itemName"><?php echo $item['sku'];?></td>
						<td class="itemDetail">
							<div class="itemImg">
								<a href="/<?php echo $item['url'];?>">
									<img src="<?php echo $item['img']?>" alt="" />
								</a>
							</div>
							<div class="itemText">
								<a href="/<?php echo $item['url'];?>" title=""><?php echo $item['product_name'];?></a>
							</div>
						</td>
						<td class="size"><?php echo $item['size'];?></td>
						<td class="bagQty">
								<a href="#" class="qtyreduce" onclick="postqty(-1,<?php echo $item['product_id'];?>,<?php echo $item['product_price'];?>)">&nbsp;</a>
								<input type="text" id="qty<?php echo $item['product_id'];?>" class="qtyInput" size="3" value="<?php echo $item['qty'];?>" name="" 
								onblur="this.value=!this.value?'0':this.value;" onfocus="if (this.value == '0') {this.value=''}" 
								onkeypress="return isNumberKey(event)" onkeyup="change_qty(<?php echo $item['product_id'];?>,<?php echo $item['product_price'];?>);"/>
								<a href="#" onclick="postqty(1,<?php echo $item['product_id'];?>,<?php echo $item['product_price'];?>)" class="qtyadd">&nbsp;</a>
							</td>
						<td class="bagPrice color01"><?php echo $symbol;?><?php echo ceil($item['product_price']*($currency->rate)*100)/100;?></td>
						<td class="totalPrice color01"><?php echo $symbol;?><span id="sub_tot_dis<?php echo $item['product_id'];?>"><?php echo $eachtotal = ceil($item['product_price']*$item['qty']*($currency->rate)*100)/100; $subtotal += $eachtotal;?></span></td>
						<td class="action">
							<a href="/cartdelete/<?php echo $item['product_id']?>"
									class="del">delete</a>
						</td>
					</tr>
              <?php endforeach;?>
            </table>

				<div class="totalArea">
					Basket Subtotal:<span id="sub_tot"><?php echo $symbol;?><?php echo $subtotal; ?></span>
					
					<br/>
					
					Shipping fee:<span id="shippfee"><?php echo $symbol;?><?php echo $shippingfee; ?></span>
					
					<br/>
					
					Total:<span id="tot"><?php echo $symbol;?><?php echo $shippingfee+$subtotal; ?></span>

				</div>
				<div class="cartBtn fix ">
					<a href="/" class="continueBtn">Continue Shopping</a>
					<a href="/do_pay" target="_self">
						<input type="submit" class="checkoutBtn"
							value="Proceed to Checkout" />
					</a>
				</div>
			</div>
		</div>
	</div>
</div>
<!--container end-->